package rc.work.module.bpm.dal.mysql.problem;

import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
import rc.work.framework.common.pojo.PageResult;
import rc.work.framework.mybatis.core.query.LambdaQueryWrapperX;
import rc.work.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import rc.work.module.bpm.controller.admin.problem.vo.ProblemBpmPageReqVO;
import rc.work.module.bpm.controller.admin.problem.vo.ProblemBpmRespVO;
import rc.work.module.bpm.dal.dataobject.problem.ProblemBpmDO;

import java.util.List;

/**
 * 流程记录 Mapper
 *
 * @author A
 */
@Mapper
public interface ProblemBpmMapper extends BaseMapperX<ProblemBpmDO> {

    default PageResult<ProblemBpmDO> selectPage(ProblemBpmPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProblemBpmDO>()
                .eqIfPresent(ProblemBpmDO::getInsId, reqVO.getInsId())
                .eqIfPresent(ProblemBpmDO::getFqsj, reqVO.getFqsj())
                .eqIfPresent(ProblemBpmDO::getFqrId, reqVO.getFqrId())
                .likeIfPresent(ProblemBpmDO::getFqrName, reqVO.getFqrName())
                .eqIfPresent(ProblemBpmDO::getFqrDeptId, reqVO.getFqrDeptId())
                .likeIfPresent(ProblemBpmDO::getFqrDeptName, reqVO.getFqrDeptName())
                .eqIfPresent(ProblemBpmDO::getJsrId, reqVO.getJsrId())
                .likeIfPresent(ProblemBpmDO::getJsrName, reqVO.getJsrName())
                .eqIfPresent(ProblemBpmDO::getJsrDeptId, reqVO.getJsrDeptId())
                .likeIfPresent(ProblemBpmDO::getJsrDeptName, reqVO.getJsrDeptName())
                .eqIfPresent(ProblemBpmDO::getBlyj, reqVO.getBlyj())
                .betweenIfPresent(ProblemBpmDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProblemBpmDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(ProblemBpmDO::getId));
    }

    /**
     * 根据问题分组ID查询问题流程记录
     *
     * @param groupId 问题分组ID
     * @return 问题流程记录列表
     */
    List<ProblemBpmRespVO> getHistory(@Param("groupId") String groupId);
}